// CourseMapper.java
@Mapper
public interface CourseMapper {
    // 根据ID查询课程（包含剩余容量）
    @Select("SELECT * FROM course WHERE id = #{id}")
    Course selectCourseById(Integer id);

    // 更新课程容量（原子操作，避免超卖）
    @Update("UPDATE course SET capacity = capacity - 1 WHERE id = #{courseId} AND capacity > 0")
    int decreaseCourseCapacity(Integer courseId);
}